/*
 * SignalOutput.java
 *
 * Created on Jan 13, 2012
 *
 * Copyright (c) 2011 Artur Rataj.
 *
 * This code is distributed under the terms of the GNU Library
 * General Public License, either version 3 of the license or, at
 * your option, any later version.
 */

package pl.gliwice.iitis.spatialnn.propagate;

import pl.gliwice.iitis.spatialnn.network.Membrane;
import pl.gliwice.iitis.spatialnn.network.MembraneType;

/**
 * A single output of <code>Signal</code>.
 * 
 * @author Artur Rataj
 */
public class SignalOutput {
    /**
     * Output of this signal, if it is a signal too.
     */
    public Signal outSignal;
    /**
     * Output of this signal, if it is a membrane.
     */
    public Membrane outMembrane;
    /**
     * If <code>outSignal != null</code>, then <code>outSignal</code>'s input index;
     * if <code>outMembrane != null</code>, then <code>outMembrane</code>'s connection
     * index.
     */
    int outIndex;

    /**
     * Creates a new instance of <code>SignalOutput</code>, representing a
     * membrane.
     * 
     * @param membrane membrane
     * @param connectionIndex index of a connection in the membrane
     */
    public SignalOutput(Membrane membrane, int connectionIndex) {
        outSignal = null;
        outMembrane = membrane;
        outIndex = connectionIndex;
        if(outMembrane.type != MembraneType.OUT)
            throw new RuntimeException("invalid membrane type");
    }
    /**
     * Creates a new instance of <code>SignalOutput</code>, representing a
     * signal.
     * 
     * @param signal a signal
     * @param inIndex index of an input in the other signal
     */
    public SignalOutput(Signal signal, int inIndex) {
        outSignal = signal;
        outMembrane = null;
        outIndex = inIndex;
    }
}
